﻿
@{
    ViewBag.Title = "News";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
<link href="../../Content/Styles/page.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-ui-1.8.24.js" type="text/javascript"></script>
<link href="../../Content/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
<link href="../../Content/themes/base/jquery.ui.dialog.css" rel="stylesheet" type="text/css" />
<style>
    #newbox
    {
        padding: 10px;
    }
    #imagenew
    {
        width: 300px;
        float: left;
        margin-right: 10px;
    }
    .ui-dialog {
        margin-top: 20px!important;
        margin-left: 60px!important;
    }
    #managenew {
        color: #5b0f32;
        cursor: pointer;
    }
</style>
<script type="text/javascript">
    function DeleteNewsCf(newsId) {
        $(document).each(function() {
            $("#dialog-confirm-deletenews").dialog({
                resizable: false,
                height: 140,
                modal: true,
                buttons: {
                    "Delete": function() {
                        DeleteNews(newsId);
                        $(this).dialog("close");
                    },
                    "Cancel": function() {
                        $(this).dialog("close");
                    }
                }
            });
        });
    }

    function DeleteNews(newsId) {
        var url = "/ManageNews/Delete";
        $.ajax({
            type: "Post",
            url: url,
            data: { newID: newsId }, // them bien neu muon truyen them
            success: function (data) {
                window.location.href = "/ManageNews/ManageNews";
            }
        });
    }
</script>
<div id="newbox">
    
    @if (ViewBag.listNews != null)
    {
        foreach (var item in ViewBag.listNews)
        {
            <div style="border-bottom: 1px solid #D8D8D8;margin-top: 10px;height: auto" >
                <div id="imagenew"><img src="@item.image" alt="Image" height="100px" width="150px" /></div>
              
                <div>
                    <p style="font-size: 23px;padding-top: 5px;color: goldenrod;">@item.title </p>
                    <div> @item.header <br /> Date create : @item.pubDate</div>
                    <div><a href="/News/ReadNew?newID=@item.ID">Read More</a> </div>
                    @*<a href = "/ManageNews/ConfirmDelete?newID=@item.ID&title=@item.title">Delete news</a>*@
                    <a href="#" onclick="DeleteNewsCf(@item.ID)">Delete News</a>
                </div>
            </div>
                                     
        }
    }
    else
    {
        <h2>New is empty</h2>
    }
</div>
<div id="dialog-confirm-deletenews" title="Delete News" style="display: none;">
                        <p style="color: Red">
                            <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
                            Are you sure to delete this news?</p>
                    </div>